import type { PluginOption } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import createAutoImport from "./auto-import";
import createComponents from "./components";
import createSvgIcon from "./svg-icon";
import createCompression from "./compression";
import createSetupExtend from "./setup-extend";

export default function createVitePlugins(viteEnv: Record<string, string>, isBuild = false) {
  const vitePlugins: PluginOption[] = [
    vue(),
    vueJsx(),
    createAutoImport(),
    createComponents(),
    createSetupExtend(),
    createSvgIcon(isBuild)
  ];
  isBuild && vitePlugins.push(...createCompression(viteEnv));
  return vitePlugins;
}
